export const count = (state) => state.count

export const cartCount = (state) => {
  var cartCt = 0
  state.shoplist.forEach(element => {
    cartCt += element.count
  })
  return cartCt
}

export const getGoodsCount = state => {
  var o = {}
  state.shoplist.forEach(element => {
    o[element.id] = element.count
  })
  return o
}

export const getGoodsSelect = state => {
  var o = {}
  state.shoplist.forEach(element => {
    o[element.id] = element.selected
  })
  return o
}

export const getGoodsCountAndAmount = state => {
  var o = {count: 0, amount: 0}

  state.shoplist.forEach(element => {
    if (element.selected) {
      o.count += element.count
      o.amount += element.count * element.price
    }
  })
  return o
}
